﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZGAssemblerLib;

public class JSHelper
{

	#region 读取文件
	public static byte[] ReadFile(string filePath) => File.ReadAllBytes(filePath);
	#endregion 读取文件

	#region 保存文件
	public static void SaveFile(string filePath, byte[] data) => File.WriteAllBytes(filePath, data);

	#endregion 保存文件

	#region 获取文件类型
	public static string PathType(string filePath)
	{
		if (File.Exists(filePath))
			return "file";

		if (Directory.Exists(filePath))
			return "path";

		return "none";
	}
	#endregion 获取文件类型

	#region 显示消息
	public static void ShowMessage(string message) => Console.WriteLine(message);

	#endregion 显示消息

}

public class JSConsole
{
	public void log(object obj) => Console.WriteLine(obj);
	public void error(object obj) => Console.WriteLine(obj);
}

public class JSTextEncoder
{
	public byte[] encode(string text) => Encoding.UTF8.GetBytes(text);
}

public class JSTextDecoder
{
	public string decode(byte[] data) => Encoding.UTF8.GetString(data);
}

public class OutDiagnosticMsg
{
	public string filePath { get; set; }
	public int line { get; set; }
	public int start { get; set; }
	public int length { get; set; }
	public string message { get; set; }
}
